package sismed.gui.comando;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sismed.exception.DAOException;
import sismed.negocio.fachada.Fachada;
import sismed.negocio.modelo.Exame;


public class ComandoRecuperarExameUrinalise extends ComandoGenerico {

	@Override
	public void executar( HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		if( request.getSession().getAttribute( "tipoUsuario" ).equals( null ) )				
			response.sendRedirect("login.jsp");
		else{
			Fachada fachada = Fachada.getInstance();		
			
					
			try  {
				List<Exame> lista = fachada.recuperarExamesPorPaciente( Integer.parseInt( request.getParameter("id") ) );	
				request.setAttribute("ListaExame", lista);
				request.setAttribute("teste", "ok");
				request.getRequestDispatcher("VerExameUrinalise2.jsp").forward(request, response);	
			} 
			catch (DAOException e) {
				request.getRequestDispatcher("VerExameUrinalise2.jsp").forward(request, response);	
			}
		}
	}

}
